<extend name="Public/base"/>
<block name="body">
  <!-- 标题栏 -->
  
  <div class="main-title">
    <h2>客户列表</h2>
  </div>
<div class="tools"> <a class="btn" href="{:U('add')}">新 增</a>
    
    <!-- 高级搜索 -->
    <div class="search-form fr cf">
			<div class="sleft">
				<div class="drop-down">
					<span id="sch-sort-txt" class="sort-txt" data="{$status}"><if condition="get_status_customer($status) eq ''">所有<else/>{:get_status_customer($status)}</if></span>
					<i class="arrow arrow-down"></i>
					<ul id="sub-sch-menu" class="nav-list hidden">
						<li><a href="javascript:;" value="">所有</a></li>
						<li><a href="javascript:;" value="1">新客户</a></li>
						<li><a href="javascript:;" value="2">跟进中</a></li>
						<li><a href="javascript:;" value="3">待分配</a></li>
                        <li><a href="javascript:;" value="4">待审核</a></li>
					</ul>
				</div>
				<input type="text" name="key" class="search-input" value="{:I('key')}" placeholder="请输入姓名或电话">
				<a class="sch-btn" href="javascript:;" id="search" url="{:U('Customer/index')}"><i class="btn-search"></i></a> 
			</div>
            
		</div>
  </div>
  
  <!-- 数据列表 -->
  <div class="data-table category">
    <div class="data-table table-stripe">
      <table class="">
        <thead>
          <tr>
            <th class="">编号</th>
            <th>姓名</th>
            <th class="">公司名称</th>
            <th class="">电话</th>
            <th class="">邮箱</th>
            <th class="">地址</th>
            <th class="">添加时间</th>
            <th class="">状态</th>
            <th class="">操作</th>
          </tr>
        </thead>
        <tbody class="">
          <notempty name="_list">
          <volist name="_list" id="vo">
   
            <tr id="{$vo.id}">
                <td>{$vo.id} </td>
                <td title="{$vo.description}">{$vo.name}</td>
                <td>{$vo.company}</td>
                <td>{$vo.phone}, {$vo.phone1}</td>
                <td>{$vo.email}</td>
                <td>{$vo.address}</td>
                <td>{$vo.addtime|time_format}</td>
                <td>{$vo.status|customerStatus}</td>
                <td>
                <switch name="vo.status">
                	<case value="3">
                    	<a href="{:U('allocation', 'id='.$vo['id'])}">分配</a>
                        <a href="{:U('CustomerLog/view', 'cid='.$vo['id'])}">日志</a>
                    </case>
                	<case value="4">
                    	<a class="confirm ajax-get" href="{:U('Customer/setStatusCustomer', 'ids='.$vo['id'].'&status=1')}">审核</a>
                    </case>
                    <default />
                      <a href="{:U('edit', 'id='.$vo['id'])}">编辑</a>
                 	  <a href="{:U('Order/add', 'cid='.$vo['id'])}">下单</a>
                  	  <a href="{:U('CustomerLog/view', 'cid='.$vo['id'])}">日志</a>
                      <a href="{:U('allocation', 'id='.$vo['id'])}">分配</a>       
                </switch>        
                </td>
            </tr>
          </volist>
          <else/>
        <td colspan="8" class="text-center"> aOh! 暂时还没有内容! </td>
            </notempty>
            </tbody>
      </table>
    </div>
  </div>
  <div class="page"> {$_page} </div>
</block>
<block name="script">

  <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
  <script type="text/javascript">

		
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
		var status = $("#sch-sort-txt").attr("data");
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
		if(status != ''){
			query = 'status=' + status + "&" + query;
        }
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});

	/* 状态搜索子菜单 */
	$(".search-form").find(".drop-down").hover(function(){
		$("#sub-sch-menu").removeClass("hidden");
	},function(){
		$("#sub-sch-menu").addClass("hidden");
	});
	$("#sub-sch-menu li").find("a").each(function(){
		$(this).click(function(){
			var text = $(this).text();
			$("#sch-sort-txt").text(text).attr("data",$(this).attr("value"));
			$("#sub-sch-menu").addClass("hidden");
		})
	});
 //回车自动提交
    $('.search-form').find('input').keyup(function(event){
        if(event.keyCode===13){
            $("#search").click();
        }
    });
    //导航高亮
    highlight_subnav('{:U('Customer/index')}');
</script>
</block>
